package top.ytazwc.controller;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.ytazwc.service.UserService;

/**
 * @author 花木凋零成兰
 * @title UserController
 * @date 2024/4/18 13:42
 * @package top.ytazwc.controller
 * @description TODO
 */
@RestController
@RequestMapping("/user")
public class UserController {

    // 注入Service
//    @Autowired  // 本地注入
//    private UserService userService;

    /**
     * 1. 从zookeeper注册中心获取UserService的访问url
     * 2. 进行远程调用 rpc
     * 3. 将结果封装为一个代理对象 给变量赋值
     */
    @Reference  // 远程注入
    private UserService userService;

    @RequestMapping("/sayHello")
    public String sayHello() {
        return userService.sayHello();
    }

}
